package Leetcode.链表;

/**
 * @ClassName 删除中间结点
 * @since: 2023/8/17 15:53
 * @auth: kirito
 * @description:
 **/
public class 删除中间结点 {
    public ListNode deleteMiddle(ListNode head) {
        if (head == null || head.next == null) {
            return null;
        }
        ListNode slow = head;
        ListNode fast = head.next;
        while (fast.next != null && fast.next.next != null) {
            slow = slow.next;
            fast = fast.next.next;
        }
        slow.next = slow.next.next;
        return head;
    }
}
